<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}请假审批系统{% endblock %}</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }
        
        .navbar {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 0.75rem 0;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            position: relative;
        }

        .navbar .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: nowrap;
        }

        .navbar .brand {
            font-size: 1.3rem;
            font-weight: bold;
            text-decoration: none;
            color: white;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .navbar .nav-links {
            display: flex;
            list-style: none;
            gap: 1rem;
            flex-wrap: nowrap;
            align-items: center;
        }

        .navbar .nav-links a {
            color: white;
            text-decoration: none;
            padding: 0.4rem 0.8rem;
            border-radius: 4px;
            transition: background-color 0.3s;
            font-size: 0.9rem;
            white-space: nowrap;
        }

        .navbar .nav-links a:hover {
            background-color: rgba(255,255,255,0.1);
        }

        .navbar .user-info {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            flex-shrink: 0;
        }

        .navbar .user-info span {
            font-size: 0.9rem;
            white-space: nowrap;
        }

        .navbar .user-info .btn {
            padding: 0.4rem 0.8rem;
            font-size: 0.85rem;
        }

        /* 添加汉堡菜单按钮 */
        .mobile-menu-btn {
            display: none;
            background: none;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0.5rem;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem 1rem;
        }

        .card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            padding: 2rem;
            margin-bottom: 2rem;
        }

        .card-header {
            border-bottom: 2px solid #f0f0f0;
            padding-bottom: 1rem;
            margin-bottom: 1.5rem;
        }

        .card-header h2 {
            color: #333;
            font-size: 1.5rem;
        }

        .btn {
            display: inline-block;
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 5px;
            text-decoration: none;
            cursor: pointer;
            font-size: 1rem;
            transition: all 0.3s;
            text-align: center;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
        }

        .btn-success {
            background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
            color: white;
        }

        .btn-danger {
            background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
            color: white;
        }

        .btn-warning {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
        }

        .btn-secondary {
            background: #6c757d;
            color: white;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: #333;
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 1rem;
            transition: border-color 0.3s;
        }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
        }

        .table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }

        .table th,
        .table td {
            padding: 1rem;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        .table th {
            background-color: #f8f9fa;
            font-weight: 600;
            color: #333;
        }

        .table tbody tr:hover {
            background-color: #f8f9fa;
        }

        .status-badge {
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.875rem;
            font-weight: 500;
        }

        .status-draft { background-color: #e9ecef; color: #495057; }
        .status-submitted { background-color: #cce5ff; color: #0066cc; }
        .status-supervisor-approved { background-color: #d4edda; color: #155724; }
        .status-approved { background-color: #d1ecf1; color: #0c5460; }
        .status-rejected { background-color: #f8d7da; color: #721c24; }
        .status-cancelled { background-color: #f1f3f4; color: #5f6368; }

        .alert {
            padding: 1rem;
            border-radius: 5px;
            margin-bottom: 1rem;
        }

        .alert-success {
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            color: #155724;
        }

        .alert-danger {
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
        }

        .alert-warning {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
        }

        .alert-info {
            background-color: #d1ecf1;
            border: 1px solid #bee5eb;
            color: #0c5460;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background: white;
            padding: 1.5rem;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            text-align: center;
        }

        .stat-number {
            font-size: 2rem;
            font-weight: bold;
            color: #667eea;
            margin-bottom: 0.5rem;
        }

        .stat-label {
            color: #666;
            font-size: 0.9rem;
        }

        /* 优化响应式设计，避免文字换行 */
        @media (max-width: 1024px) {
            .navbar .nav-links {
                gap: 0.5rem;
            }

            .navbar .nav-links a {
                padding: 0.3rem 0.6rem;
                font-size: 0.85rem;
            }

            .navbar .user-info span {
                display: none;
            }
        }

        @media (max-width: 900px) {
            .navbar .container {
                flex-wrap: wrap;
            }

            .navbar .nav-links {
                order: 3;
                width: 100%;
                justify-content: center;
                margin-top: 0.5rem;
                padding-top: 0.5rem;
                border-top: 1px solid rgba(255,255,255,0.2);
            }
        }

        @media (max-width: 768px) {
            .mobile-menu-btn {
                display: block;
            }

            .navbar .nav-links {
                display: none;
                position: absolute;
                top: 100%;
                left: 0;
                right: 0;
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                flex-direction: column;
                padding: 1rem;
                box-shadow: 0 2px 10px rgba(0,0,0,0.1);
                z-index: 1000;
            }

            .navbar .nav-links.show {
                display: flex;
            }

            .navbar .nav-links a {
                padding: 0.75rem 1rem;
                border-bottom: 1px solid rgba(255,255,255,0.1);
                font-size: 1rem;
            }

            .navbar .nav-links a:last-child {
                border-bottom: none;
            }

            .container {
                padding: 1rem;
            }

            .card {
                padding: 1rem;
            }

            .table {
                font-size: 0.875rem;
            }

            .table th,
            .table td {
                padding: 0.5rem;
            }
        }
    </style>
</head>
<body>
    <nav class="navbar">
        <div class="container">
            <a href="{% url 'dashboard' %}" class="brand">请假审批系统</a>

            {% if user.is_authenticated %}
            <!-- 添加移动端菜单按钮 -->
            <button class="mobile-menu-btn" onclick="toggleMobileMenu()">☰</button>

            <ul class="nav-links" id="navLinks">
                <li><a href="{% url 'dashboard' %}">首页</a></li>
                <li><a href="{% url 'apply_leave' %}">申请请假</a></li>
                <li><a href="{% url 'my_leaves' %}">我的申请</a></li>
                {% if user.userprofile.can_approve_leave %}
                <li><a href="{% url 'approval_list' %}">待审批</a></li>
                {% endif %}
                {% if user.userprofile.role == 'hr' or user.userprofile.role == 'admin' %}
                <li><a href="{% url 'all_leaves' %}">所有申请</a></li>
                <li><a href="{% url 'user_management' %}">用户管理</a></li>
                {% endif %}
            </ul>

            <div class="user-info">
                <span>欢迎，{{ user.get_full_name|default:user.username }}</span>
                <a href="{% url 'profile' %}" class="btn btn-secondary">个人资料</a>
                <a href="{% url 'logout' %}" class="btn btn-secondary">退出</a>
            </div>
            {% endif %}
        </div>
    </nav>

    <div class="container">
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }}">
                    {{ message }}
                </div>
            {% endfor %}
        {% endif %}

        {% block content %}
        {% endblock %}
    </div>

    <!-- 添加移动端菜单切换脚本 -->
    <script>
        function toggleMobileMenu() {
            const navLinks = document.getElementById('navLinks');
            navLinks.classList.toggle('show');
        }

        // 点击页面其他地方时关闭菜单
        document.addEventListener('click', function(event) {
            const navLinks = document.getElementById('navLinks');
            const menuBtn = document.querySelector('.mobile-menu-btn');

            if (!navLinks.contains(event.target) && !menuBtn.contains(event.target)) {
                navLinks.classList.remove('show');
            }
        });
    </script>
</body>
</html>
